package net.lanelife.casino.caipiao.entity;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.EnumType;
import javax.persistence.Enumerated;
import javax.persistence.Index;
import javax.persistence.Table;

import net.lanelife.casino.caipiao.entity.support.UserRelationEntity;
import net.lanelife.casino.common.entity.annotation.Checked;
import net.lanelife.casino.common.utils.BillNoUtils;

import org.hibernate.annotations.DynamicInsert;
import org.hibernate.annotations.DynamicUpdate;

@Entity
@DynamicInsert
@DynamicUpdate
@Table(name = "TB_BALANCE_CHANGE_RECORD", indexes = { 
	@Index(name = "IDX_BILLNO", columnList = "BILLNO"),
	@Index(name = "IDX_USER_ID", columnList = "USER_ID"),
	@Index(name = "IDX_USER_NAME", columnList = "USER_NAME"),
	@Index(name = "IDX_FLOOR", columnList = "FLOOR"),
	@Index(name = "IDX_PATH", columnList = "PATH"),
	@Index(name = "IDX_PARENT_ID", columnList = "PARENT_ID"),
	@Index(name = "IDX_PARENT_NAME", columnList = "PARENT_NAME")
})
public class BalanceChangeRecord extends UserRelationEntity<Integer> {

	private static final long serialVersionUID = -508534394075766331L;
	
	@Checked
	@Column(name = "BILLNO", length = 24, nullable = false)
	private String billNo = BillNoUtils.generateBillNo(BillNoUtils.PREFIX_BC);
	
	@Checked
	@Column(name = "AMOUNT", nullable = false)
	private Double amount;
	
	@Checked
	@Enumerated(EnumType.ORDINAL)
	@Column(name = "DIRECTION", nullable = false)
	private Direction direction;
	
	@Checked
	@Column(name = "REASON_CODE", length = 10, nullable = false)
	private String reasonCode;
	
	@Checked
	@Column(name = "REASON_NAME", length = 10, nullable = false)
	private String reasonName;
	
	@Checked
	@Column(name = "REMARK", length = 255, nullable = false)
	private String remark = "";

	public static enum Direction {
		IN, OUT
	}

	public String getBillNo() {
		return billNo;
	}

	public void setBillNo(String billNo) {
		this.billNo = billNo;
	}

	public Double getAmount() {
		return amount;
	}

	public void setAmount(Double amount) {
		this.amount = amount;
	}

	public Direction getDirection() {
		return direction;
	}

	public void setDirection(Direction direction) {
		this.direction = direction;
	}

	public String getReasonCode() {
		return reasonCode;
	}

	public void setReasonCode(String reasonCode) {
		this.reasonCode = reasonCode;
	}

	public String getReasonName() {
		return reasonName;
	}

	public void setReasonName(String reasonName) {
		this.reasonName = reasonName;
	}

	public String getRemark() {
		return remark;
	}

	public void setRemark(String remark) {
		this.remark = remark;
	}
	
}
